package edu.mse.camel.client.posterboard.ui.adapters;

import org.eclipse.gef.EditPart;
import org.eclipse.gef.EditPartFactory;

import edu.mse.camel.client.posterboard.posterboard.PBDiagram;
import edu.mse.camel.client.posterboard.ui.editor.PosterBoardModelManager;
import edu.mse.camel.client.posterboard.ui.editpart.AdaptedWhiteboardDiagramEditpart;
import edu.mse.camel.client.whiteboard.gef.ui.editpart.WhiteboardEditPartFactory;
import edu.mse.camel.client.whiteboard.gef.whiteboard.WhiteboardDiagram;

public class WhiteboardAdapter implements IToolAdapter {

	protected PosterBoardModelManager pbModelManager;
	
	protected WhiteboardAdapter() {
		
	}
	
	public void initialize(PosterBoardModelManager pbModelManager) {
		this.pbModelManager = pbModelManager;
	}
	
	public static WhiteboardAdapter INSTANCE = new WhiteboardAdapter();
	
	public static final String WHITEBOARD_DIAGRAM = "WhiteboardDiagram";
	
	@Override
	public EditPart getAdaptedDiagramEditpart(PBDiagram model) {
		return new AdaptedWhiteboardDiagramEditpart(model, pbModelManager);
	}

	@Override
	public EditPartFactory getEditPartFactory(EditPart context) {
		return new WhiteboardEditPartFactory();
	}

	@Override
	public EditPartFactory getEditPartFactory(String diagramType) {
		return new WhiteboardEditPartFactory();
	}

	@Override
	public boolean shouldSetDelegate(EditPart context, EditPartFactory delegate) {
		return true;
	}
	
	@Override
	public boolean isSupported(String diagramType) {
		if (diagramType.equals(WhiteboardAdapter.WHITEBOARD_DIAGRAM)) {
			return true;
		}
		return false;
	}

}
